package com.jio.mapper;

import com.jio.entity.Video;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface VideoMapper {
    @Select("select * from video where tid=#{tId}")
    List<Video> selectAll(int tId);

    @Select("select * from video where courseName like '%${name}%' or title like '%${name}%'")
    List<Video> selectLikeName(String name);

    @Insert("insert into video (courseName, title, description, videoUrl, tid) values(#{courseName}, #{title}, #{description}, #{videoUrl}, #{tid})")
    int insert(Video video);

    @Delete("delete from video where id=#{id}")
    int deleteById(int id);

    void deleteList(List<Integer> ids);

    @Select("select v.*,u.username from video v left join users u on v.tid=u.id where v.id=#{id}")
    Video selectById(int id);

    @Update("update video set courseName=#{courseName},title=#{title},description=#{description},videoUrl=#{videoUrl} where id=#{id}")
    int update(Video video);
}